package devops.katas.adminprovider;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class AdminProviderApplication {

	public static void main(String[] args) {
		SpringApplication.run(AdminProviderApplication.class, args);
	}

}

class  Admin {

	private final String firstName;
	private final String lastName;

	public Admin(String firstName, String lastName) {
		this.firstName = firstName;
		this.lastName = lastName;
	}

	// Need public getters for fixing issue "HttpMessageNotWritableException:
	// No converter found for return value of type: class devops.katas.adminprovider.Admin"
	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}
}

@RestController
class AdminController {
	@GetMapping("/admin/{id}")
	Admin admin(@PathVariable int id) {
		return new Admin("first-name", "last-name-[" + id + "]");
	}
}
